var num = 0;
ss = "";
var add={
	    inintEvent: function(){
	        $("#selection").unbind("click");
	        $("#selection").bind("click", function(){
	        	var i = $("#selection").val();
	        	if(i!="填空题"){
	        		$("#option").show();
	        	}else{
	        		$("#option").hide();
	        	}
	        });
	    },
	    buttonEvent: function(){
	    	$("#add1").unbind("click");
	    	$("#add1").bind("click", function(){
	    		num++;
	    		if(num==2){
	    			$("#add2").hide();
	    		}
	    		var mydiv = document.getElementById("option1");
	    		mylabel = document.createElement("label");
	    		myspan = document.createElement("span");
	    		myinput = document.createElement("input");
	    		if(num==1){
	    			ss = "E";
	    		}else{
	    			ss = "F";
	    		}
	    		
	    		currenttext=document.createTextNode("Option "+ss+" :");
	    		myspan.appendChild(currenttext);
	    		mylabel.appendChild(myspan);
	    		mylabel.appendChild(myinput);
	    		mydiv.appendChild(mylabel);
	    		myinput.setAttribute("type", "text");
	    		myinput.setAttribute("placeholder", "Input Option "+ss);
	    		myinput.setAttribute("name", "answer"+ss);
	    	});
	    },
	    formValidate: function(){
	        $("#button").unbind("click");
	        $("#button").bind("click", function(){
	        	var score = $("#score").val();
	        	if(isNaN(score)){
	        		alert("score必须是数字");
	        		return false;
	        	}

	            if(pwd1!=pwd2){
	            	$("#message1").text("密码不一致");
	            	return false;
	            }
	            if(pwd1==""){
	            	$("#message1").text("请输入密码");
	            	return false;
	            }
	          
	        });
	    },
};
$().ready(function(){
	add.inintEvent();
	add.buttonEvent();
	add.formValidate();
});